package xyz.lisys.action;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@Controller("fooAction")
@Scope("prototype")
public class FooAction extends ActionSupport {

    public String view() {
        // 返回json格式数据
        HttpServletResponse response = ServletActionContext.getResponse();
        try {
            PrintWriter out = response.getWriter();
            out.write("{\"name\":\"zyp\"}");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return NONE;
    }
}
